<!DOCTYPE html>
<!-- 网页使用的语言 -->
<html lang="zh-CN">
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <!-- 使用Edge最新的浏览器的渲染方式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- viewport视口：网页可以根据设置的宽度自动进行适配，在浏览器的内部虚拟一个容器，容器的宽度与设备的宽度相同。
    width: 默认宽度与设备的宽度相同
    initial-scale: 初始的缩放比，为1:1 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>图书管理</title>

    <!-- 1. 导入CSS的全局样式 -->
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="/static/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="/static/js/bootstrap.min.js"></script>
    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>
</head>
<body>
<div class="container">
    <nav class="navbar navbar-default">
          <div class="container">
            <ul class="nav navbar-nav">
                <li><a href="{% url 'presslist' %}">出版社信息</a></li>
                <li><a href="/booklist/">图书信息</a></li>
                <li><a href="/booktypelist/">图书类型信息</a></li>
            </ul>
          </div>
    </nav>
    <h3 style="text-align: center">出版社信息列表</h3>

    <form class="form-inline" method="post" action="/presssearch/">
      <div class="form-group">
        <label class="sr-only" for="pressname"></label>
        <input type="text" class="form-control" value="{{ pressname }}" id="pressname" name="pressname" placeholder="出版社名称">
      </div>
      <button type="submit" class="btn btn-default">搜索</button>
    </form>

    <table border="1" class="table table-bordered table-hover">
        <tr class="success">
            <th>编号</th>
            <th>出版社名称</th>
            <th>出版社地址</th>
            <th>操作</th>
        </tr>

        {% for press in presslist %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td>{{ press.pressname }}</td>
                <td>{{ press.pressaddress }}</td>
                <td>
                    <a class="btn btn-info glyphicon glyphicon-pencil btn-sm" href="/pressupdate/?id={{ press.id }}">修改</a>&nbsp;
                    {% comment %}<a class="btn btn-danger glyphicon glyphicon-trash btn-sm" href="/pressdelete/?id={{ press.id }}" onclick="return confirm('您确定删除吗？')">删除</a>{% endcomment %}
                    <a class="btn btn-danger glyphicon glyphicon-trash" href="/app/pressdelete/{{ press.id }}" onclick="return confirm('您确定删除吗？')">删除</a>
                    {% comment %}<a class="btn btn-danger glyphicon glyphicon-trash btn-sm" href="#" data-id="{{ press.id }}" data-toggle="modal" data-target="#myModal">删除</a>{% endcomment %}
                </td>
            </tr>
        {% endfor %}

        <tr>
            <td colspan="8" align="center"><a class="btn btn-primary glyphicon glyphicon-plus" href="/pressadd">添加出版社</a></td>
        </tr>
    </table>

<!-- 模态框 -->
{% comment %}
<div class="modal fade" id="myModal" tabindex="-1" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="myModalLabel">信思智学提醒您</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        删除后不可恢复，确定删除吗？
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id="sub">保存更改</button>
      </div>
    </div>
  </div>
</div>
{% endcomment %}


</div>


<script>
    {% comment %}$(function () {
        $('#myModal').on('show.bs.modal', function (event) {
            // 获取触发模态框的按钮
            var button = $(event.relatedTarget); // Button that triggered the modal
            // 获取 data-id 属性值
            var dataId = button.data('id'); // Extract info from data-* attributes
            // 你可以在这里使用 dataId
            $("#sub").click(function () {
                {#window.location.href = "/pressdelete/?id="+dataId#}
                window.location.href = "/pressdelete/"+dataId
            });
        });
    }){% endcomment %}
</script>

</body>
</html>
